import dgl
import dgl.function as fn
import torch
g = dgl.graph(([0, 1, 1, 3], [1, 2, 3, 2]))
g.ndata['x'] = torch.ones(4, 2)
g.update_all(fn.copy_u('x', 'm'), fn.mean('m', 'h'))
print(g.ndata['h'])
print(g)
g.update_all(fn.u_add_v('x', 'x', 'm'), fn.sum('m', 'h'))
print(g.ndata['h'])